package com.handpay.nocardpay.baselibrary.main.all.presenter;

import android.content.Context;

import com.handpay.nocardpay.baselibrary.commbase.model.IBaseModel;
import com.handpay.nocardpay.baselibrary.commbase.model.bean.BaseErrorInfo;
import com.handpay.nocardpay.baselibrary.commbase.presenter.IBasePresenter;
import com.handpay.nocardpay.baselibrary.main.all.model.CustomComponentModelImpl;
import com.handpay.nocardpay.baselibrary.main.all.model.bean.component.http.ComponentHttpBean;
import com.handpay.nocardpay.baselibrary.main.all.view.IAllView;

import java.util.HashMap;

/**
 * Created by lyang on 2018/2/7.
 */

public class CustomComponentPresenterImpl implements IBasePresenter, IBaseModel.OnRequestFinishedListener<ComponentHttpBean> {

    private CustomComponentModelImpl mCustomComponentModelImpl;
    private IAllView mAllView;
    private Context mContext;
//    private LowestAccountTransferAmount mLowestAccountTransferAmount;


    public CustomComponentPresenterImpl(IAllView allView, Context context) {
        this.mCustomComponentModelImpl = new CustomComponentModelImpl(context);
        this.mAllView = allView;
        mContext = context;
    }


    public void getCustomComponent(HashMap<String, Object> paramers, Class<ComponentHttpBean> clzz, boolean isShowLoading) {
        if (mAllView != null) {
            if (isShowLoading) {
                mAllView.showProgress();
            }
        }
        mCustomComponentModelImpl.getCustomComponentModelImpl(paramers, clzz, this);
    }

    @Override
    public void onDestory() {

    }

    @Override
    public void onError(BaseErrorInfo baseErrorInfo) {
        if (mAllView != null) {
            mAllView.hideProgress();
            mAllView.showErrorAlert(baseErrorInfo);
        }
    }

    @Override
    public void onSuccess(ComponentHttpBean response) {
        if (mAllView != null) {
            mAllView.hideProgress();
            mAllView.setCustomComponent(response);
        }
    }
}